package com.lucas.servlet.chapter3_3.service.iml;

import com.lucas.servlet.chapter3_3.entity.User;
import com.lucas.servlet.chapter3_3.mapper.UserMapper;
import com.lucas.servlet.chapter3_3.service.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class LoginServiceIml implements LoginService {
    @Autowired
    UserMapper userMapper;

    @Override
    public boolean login(String username, String password){
        User user=userMapper.getUserByName(username,password);
        if(user == null){
            log.info("用户名或密码错误");
        } else if (user.getPassword().equals(password)) {
            log.info("登录成功");
            return true;
        }
        log.info("登陆失败");
        return false;
    }
}
